<template>

  <div>
    <!-- 幻灯片 开始 -->
    <div v-swiper:mySwiper="swiperOption">
      <div class="swiper-wrapper">

        <div v-for="banner in bannerList" :key="banner.id" class="swiper-slide" style="background: #040B1B;">
          <a target="_blank" :href="banner.linkUrl">
            <img :src="banner.imageUrl" :alt="banner.name">
          </a>
        </div>
      </div>
      <div class="swiper-pagination swiper-pagination-white"></div>
      <div class="swiper-button-prev swiper-button-white" slot="button-prev"></div>
      <div class="swiper-button-next swiper-button-white" slot="button-next"></div>
    </div>
    <!-- 幻灯片 结束 -->

    <div id="aCoursesList">
      <!-- 热门汽车 开始 -->
      <div>
        <section class="container">
          <header class="comm-title">
            <h2 class="tac">
              <span class="c-333">热门汽车</span>
            </h2>
          </header>
          <div>
            <article class="comm-course-list">
              <ul class="of" id="bna">
                <li v-for="AutomobileList in automobileList" :key="AutomobileList.id">
                  <div class="cc-l-wrap">
                    <section class="course-img">
                      <img
                        :src="AutomobileList.fileName"
                        class="img-responsive"
                        :alt="AutomobileList.productName"
                      >
                      <div class="cc-mask">
                        <a :href="'/automobile/'+AutomobileList.id" :title="AutomobileList.productName"
                           class="comm-btn c-btn-1">{{ AutomobileList.productName }}</a>
                      </div>
                    </section>
                    <h3 class="hLh30 txtOf mt10">
                      <a :href="'/automobile/'+AutomobileList.id" :title="AutomobileList.productName"
                         class="course-title fsize18 c-333">{{ AutomobileList.productName }}</a>
                    </h3>
                    <section class="mt10 hLh20 of">
                      <span class="fr jgTag bg-green">
                        <i class="c-fff fsize12 f-fA">￥{{ AutomobileList.productPrice }}</i>
                      </span>
                      <span class="fl jgAttr c-ccc f-fA">
                        <i class="c-999 f-fA">汽车销量:{{ AutomobileList.productSales }}</i>
                        |
                        <i class="c-999 f-fA">汽车库存:{{ AutomobileList.productQuantity }}</i>
                      </span>
                    </section>
                  </div>
                </li>

              </ul>
              <div class="clear"></div>
            </article>
            <section class="tac pt20">
              <a href="/automobile" title="全部汽车" class="comm-btn c-btn-2">全部汽车</a>
            </section>
          </div>
        </section>
      </div>
      <!-- /热门汽车结束 结束 -->
      <!-- 创始人 开始 -->
      <div>
        <section class="container">
          <header class="comm-title">
            <h2 class="tac">
              <span class="c-333">创始人</span>
            </h2>
          </header>
          <div>
            <article class="i-teacher-list">
              <ul class="of">
                <li v-for="FounderList in founderList" :key="FounderList.id">
                  <section class="i-teach-wrap">
                    <div class="i-teach-pic">
                      <a :href="'/founder/'+FounderList.id" :title="FounderList.name">
                        <img :alt="FounderList.name" :src="FounderList.picture">
                      </a>
                    </div>
                    <div class="mt10 hLh30 txtOf tac">
                      <a :href="'/founder/'+FounderList.id" :title="FounderList.name" class="fsize18 c-666">{{ FounderList.name }}</a>
                    </div>
                    <div class="mt15 i-q-txt">
                      <p
                        class="c-999 f-fA"
                      >{{ FounderList.intro }}</p>
                    </div>
                  </section>
                </li>

              </ul>
              <div class="clear"></div>
            </article>
            <section class="tac pt20">
              <a href="/founder" title="全部创始人" class="comm-btn c-btn-2">全部创始人</a>
            </section>
          </div>
        </section>
      </div>
      <!-- /创始人 结束 -->
    </div>
  </div>
</template>

<script>
import banner from '@/api/banner'
import index from '@/api/index'

export default {
  data() {
    return {
      swiperOption: {
        //配置分页
        pagination: {
          el: '.swiper-pagination'//分页的dom节点
        },
        //配置导航
        navigation: {
          nextEl: '.swiper-button-next',//下一页dom节点
          prevEl: '.swiper-button-prev'//前一页dom节点
        }
      },
      //banner两条数据
      bannerList: [],
      //八条热门汽车数据
      automobileList: [],
      //四名创始人
      founderList: []
    }
  },
  created() {

    //调用查询banner的方法
    this.getBannerList()
    // 查询八辆热门汽车和四名创始人
    this.getAutomobileFounder();

  },
  methods: {

    //查询banner数据
    getBannerList() {
      banner.getListBanner()
        .then(response => {
          console.log(response)
          this.bannerList = response.data.data.list
        })
    },


    //查询八辆热门汽车和四名创始人
    getAutomobileFounder() {
      index.getIndexList()
        .then(response => {
          console.log(response)
          this.automobileList = response.data.data.automobileList
          this.founderList = response.data.data.founderList
        })
    },

  }
}
</script>
